package org.kealinghornets.jchuah.buttons;

import android.content.Intent;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Toast;



public class MainActivity extends ActionBarActivity {

    public void checkvictory() {
        View left_crosshair = findViewById(R.id.left_crosshair);
        View middle_crosshair = findViewById(R.id.middle_crosshair);
        View right_crosshair = findViewById(R.id.right_crosshair);
        if (left_crosshair.getVisibility() == View.VISIBLE && middle_crosshair.getVisibility() == View.VISIBLE && right_crosshair.getVisibility() == View.VISIBLE)
            Toast.makeText(this, "YOU ARE A WEINNER!!!!!!", Toast.LENGTH_LONG).show();
            startActivity(new Intent(this, Leaval2.class));
        }

       public void toggleVisibility(int id) {
           View crosshair;

           crosshair = findViewById(id);

           if (crosshair.getVisibility() == View.INVISIBLE) {
               crosshair.setVisibility(View.VISIBLE);
           } else {

                   crosshair.setVisibility(View.INVISIBLE);
               }
           }

    public void onleftbuttonpush (View view) {
          Toast.makeText(this, "U TAPPED DAT!!!!", Toast.LENGTH_SHORT).show();
          toggleVisibility(R.id.left_crosshair);
        checkvictory();
    }
    public void onmiddlePush(View view) {
          Toast.makeText(this,"plz (t)work", Toast.LENGTH_SHORT).show();
          toggleVisibility(R.id.middle_crosshair);
        checkvictory();
    }
    public void onrightbuttonPush(View view) {
          Toast.makeText(this,"MY MAMA IS A PERSON", Toast.LENGTH_SHORT).show();
          toggleVisibility(R.id.right_crosshair);
        checkvictory();
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }


    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.menu_main, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();

        //noinspection SimplifiableIfStatement
        if (id == R.id.action_settings) {
            return true;
        }

        return super.onOptionsItemSelected(item);
    }
}
